home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 2.iso / toolbox / perfTuning / XandSysPerf / xprotostats < prev    next >
Text File  |  1996-11-11  |  7KB  |  249 lines

  1. #!/bin/sh
  2. #
  3. # xprotostats - an xscope protocol trace groaker
  4. #   Mark Kilgard
  5. #   11/5/93
  6. #
  7.  
  8. # XXX grep out the X ResourceDB since it is too long for awk
  9. grep -v "value:" | awk '
  10.  
  11. # single-client Client IO case
  12. NF == 5 && $2 == "Client" {
  13.   client_batches++
  14.   client_bytes += $4
  15. }
  16.  
  17. # multi-client Client IO case
  18. NF == 6 && $2 == "Client" {
  19.   client_batches++
  20.   client_bytes += $5
  21. }
  22.  
  23. # request gotten
  24. NF == 2 && $1 == "............REQUEST:" {
  25.   client_requests++
  26.    
  27.   # try looking for dubious round-trip requests
  28.   if ($2 == "AllocColor") {
  29.      AllocColor++;
  30.   } else 
  31.   if ($2 == "AllocColorCells") {
  32.      AllocColorCells++;
  33.   } else 
  34.   if ($2 == "AllocColorPlanes") {
  35.      AllocColorPlanes++;
  36.   } else 
  37.   if ($2 == "AllocNamedColor") {
  38.      AllocNamedColor++
  39.   } else 
  40.   if ($2 == "ClearArea") {
  41.      ClearArea++
  42.   } else 
  43.   if ($2 == "GetAtomName") {
  44.      GetAtomName++
  45.   } else 
  46.   if ($2 == "GetFontPath") {
  47.      GetFontPath++
  48.   } else 
  49.   if ($2 == "GetGeometry") {
  50.      GetGeometry++
  51.   } else 
  52.   if ($2 == "GetInputFocus") {
  53.      GetInputFocus++
  54.   } else 
  55.   if ($2 == "GetKeyboardMapping") {
  56.      GetKeyboardMapping++
  57.   } else 
  58.   if ($2 == "GetModifierMapping") {
  59.      GetModifierMapping++
  60.   } else 
  61.   if ($2 == "GetPointerMapping") {
  62.      GetPointerMapping++
  63.   } else 
  64.   if ($2 == "GetSelectionOwner") {
  65.      GetSelectionOwner++
  66.   } else 
  67.   if ($2 == "GetWindowAttributes") {
  68.      GetWindowAttributes++
  69.   } else 
  70.   if ($2 == "InternAtom") {
  71.      InternAtom++
  72.   } else 
  73.   if ($2 == "ListFonts") {
  74.      ListFonts++
  75.   } else 
  76.   if ($2 == "ListProperties") {
  77.      ListProperties++
  78.   } else 
  79.   if ($2 == "QueryBestSize") {
  80.      QueryBestSize++
  81.   } else 
  82.   if ($2 == "QueryColors") {
  83.      QueryColors++
  84.   } else 
  85.   if ($2 == "QueryExtension") {
  86.      QueryExtension++
  87.   } else 
  88.   if ($2 == "QueryFont") {
  89.      QueryFont++
  90.   } else 
  91.   if ($2 == "QueryKeymap") {
  92.      QueryKeymap++
  93.   } else 
  94.   if ($2 == "QueryPointer") {
  95.      QueryPointer++
  96.   } else 
  97.   if ($2 == "QueryTextExtents") {
  98.      QueryTextExtents++
  99.   } else 
  100.   if ($2 == "QueryTree") {
  101.      QueryTree++
  102.   } else 
  103.   if ($2 == "TranslateCoordinates") {
  104.      TranslateCoordinates++
  105.   }
  106. }
  107.  
  108. # extension request gotten
  109. NF == 4 && $1 == "#######" && $3 == "request" {
  110.   client_requests++
  111. }
  112.  
  113. # extension event gotten
  114. NF == 4 && $1 == "#######" && $3 == "Event" {
  115.   server_events++
  116. }
  117.  
  118. # extension reply gotten
  119. NF == 3 && $1 == "#######" && $3 == "reply" {
  120.   server_replies++
  121. }
  122.  
  123. # single-client Server IO case
  124. NF == 6 && $5 == "X11" && $6 == "Server" {
  125.   server_batches++
  126.   server_bytes += $2
  127. }
  128.  
  129. # multi-client Server IO case
  130. NF == 7 && $5 == "X11" && $6 == "Server" {
  131.   server_batches++
  132.   server_bytes += $2
  133. }
  134.  
  135. # reply gotten
  136. NF == 2 && $1 == "..............REPLY:" {
  137.   server_replies++
  138. }
  139.  
  140. # event gotten
  141. NF == 2 && $1 == "..............EVENT:" {
  142.   server_events++
  143.  
  144.   # try looking for dubious events requests
  145.   if ($2 == "NoExposure") {
  146.      NoExposure++;
  147.   } else 
  148.   if ($2 == "SendMessage") {
  149.      NoExposure++;
  150.   } else 
  151.   if ($2 == "PropertyNotify") {
  152.      NoExposure++;
  153.   }
  154. }
  155.  
  156. # error gotten
  157. NF == 2 && $1 == "..............ERROR:" {
  158.   server_events++
  159. }
  160.  
  161. END {
  162.   print
  163.   print "RAW CLIENT PROTOCOL STATISITICS:"
  164.   printf("  bytes written:         %10d\n", client_bytes)
  165.   printf("  batches written:       %10d\n", client_batches)
  166.   printf("  requests made:         %10d\n", client_requests)
  167.   print "RAW SERVER PROTOCOL STATISITICS:"
  168.   printf("  bytes written:         %10d\n", server_bytes)
  169.   printf("  batches written:       %10d\n", server_batches)
  170.   printf("  replies made:          %10d\n", server_replies)
  171.   printf("  events sent:           %10d\n", server_events)
  172.   printf("  errors sent:           %10d\n", server_errors)
  173.   print "COMPUTED STATISTICS:"
  174.   if (client_requests != 0)
  175.      printf("  replies/request:           %6.2f %%\n", server_replies/client_requests*100.0)
  176.   else
  177.      printf("  replies/request:              n/a\n")
  178.   if (client_bytes != 0)
  179.      printf("  server/client data:        %6.2f %%\n", server_bytes/client_bytes*100.0)
  180.   else
  181.      printf("  server/client data:           n/a\n")
  182.   if (client_requests != 0)
  183.      printf("  bytes/request:             %6.2f bytes\n", client_bytes/client_requests)
  184.   else
  185.      printf("  bytes/request:                n/a\n")
  186.   print "OFTEN MISUSED ROUND-TRIP REQUESTS:"
  187.   if(AllocColor > 0)
  188.      printf("  AllocColor               %8d\n", AllocColor)
  189.   if(AllocColorCells > 0)
  190.      printf("  AllocColorCells          %8d\n", AllocColorCells)
  191.   if(AllocColorPlanes > 0)
  192.      printf("  AllocColorPlanes         %8d\n", AllocColorPlanes)
  193.   if(AllocNamedColor > 0)
  194.      printf("  AllocNamedColor          %8d\n", AllocNamedColor)
  195.   if(GetAtomName > 0)
  196.      printf("  GetAtomName              %8d\n", GetAtomName)
  197.   if(GetFontPath > 0)
  198.      printf("  GetFontPath              %8d\n", GetFontPath)
  199.   if(GetGeometry > 0)
  200.      printf("  GetGeometry              %8d\n", GetGeometry)
  201.   if(GetInputFocus > 0)
  202.      printf("  GetInputFocus            %8d\n", GetInputFocus)
  203.   if(GetKeyboardMapping > 0)
  204.      printf("  GetKeyboardMapping       %8d\n", GetKeyboardMapping)
  205.   if(GetModifierMapping > 0)
  206.      printf("  GetModifierMapping       %8d\n", GetModifierMapping)
  207.   if(GetPointerMapping > 0)
  208.      printf("  GetPointerMapping        %8d\n", GetPointerMapping)
  209.   if(GetSelectionOwner > 0)
  210.      printf("  GetSelectionOwner        %8d\n", GetSelectionOwner)
  211.   if(GetWindowAttributes > 0)
  212.      printf("  GetWindowAttributes      %8d\n", GetWindowAttributes)
  213.   if(InternAtom > 0)
  214.      printf("  InternAtom               %8d\n", InternAtom)
  215.   if(ListFonts > 0)
  216.      printf("  ListFonts                %8d\n", ListFonts)
  217.   if(ListProperties > 0)
  218.      printf("  ListProperties           %8d\n", ListProperties)
  219.   if(QueryBestSize > 0)
  220.      printf("  QueryBestSize            %8d\n", QueryBestSize)
  221.   if(QueryColors > 0)
  222.      printf("  QueryColors              %8d\n", QueryColors)
  223.   if(QueryExtension > 0)
  224.      printf("  QueryExtension           %8d\n", QueryExtension)
  225.   if(QueryFont > 0)
  226.      printf("  QueryFont                %8d\n", QueryFont)
  227.   if(QueryKeymap > 0)
  228.      printf("  QueryKeymap              %8d\n", QueryKeymap)
  229.   if(QueryPointer > 0)
  230.      printf("  QueryPointer             %8d\n", QueryPointer)
  231.   if(QueryTextExtents > 0)
  232.      printf("  QueryTextExtents         %8d\n", QueryTextExtents)
  233.   if(QueryTree > 0)
  234.      printf("  QueryTree                %8d\n", QueryTree)
  235.   if(TranslateCoordinates > 0)
  236.      printf("  TranslateCoordinates     %8d\n", TranslateCoordinates)
  237.   print "OFTEN MISUSED NON-ROUND-TRIP REQUESTS:"
  238.   if(ClearArea > 0)
  239.      printf("  ClearArea                %8d\n", ClearArea)
  240.   print "OFTEN MISUSED EVENTS:"
  241.   if(ClientMessage > 0)
  242.      printf("  ClientMessage            %8d\n", ClientMessage)
  243.   if(NoExposure > 0)
  244.      printf("  NoExposure               %8d\n", NoExposure)
  245.   if(PropertyNotify > 0)
  246.      printf("  PropertyNotify           %8d\n", PropertyNotify)
  247.   print
  248. }' -
  249.